import { ecs } from "db://app-game/libs/ecs/ECS";
import { DBJoysitick } from "../../../common/db/db-joysitick/DBJoysitick";
import { DBJoysitickType } from "../../../common/db/db-joysitick/DBJoysitick.type";
import { JoysitickNameEnum } from "../Joysitick.type";

/**
 * @en The joystick model component
 * @zh 摇杆模型组件
 */
@ecs.register("JoysitickModel")
export class JoysitickModelComp extends ecs.Comp {
  db: DBJoysitick = new DBJoysitick();
  _id: number = -1;
  /** 角色编号 */
  get id(): number {
    return this._id;
  }
  set id(val: number) {
    this._id = val;
    this.db.init(val);
    this.data = this.db.data;
  }
  /** 摇杆数据 */
  data: DBJoysitickType = null!;

  name: JoysitickNameEnum = JoysitickNameEnum.JoysitickL;

  reset(entity: ecs.Entity): void {
    this._id = -1;
    this.data = null!;
    this.name = JoysitickNameEnum.JoysitickL;
  }
}
